﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using RZD_maps.Modules.Stations.ViewModels;

namespace RZD_maps.Modules.Stations.Views
{
    /// <summary>
    /// Логика взаимодействия для StationsView.xaml
    /// </summary>
    public partial class StationsView : UserControl
    {
        private ViewModel viewModel;

        public StationsView()
        {
            InitializeComponent();
        }

        public StationsView(ViewModel viewModel) : this()
    {
        this.viewModel = viewModel;
        viewModel.View = this;
    }

        private void CategoryTree_SelectedItemChanged(object sender, Hardcodet.Wpf.GenericTreeView.RoutedTreeItemEventArgs<Model.StationCategory> e)
        {
            double lng,lat;
            string name = "";
            lng = 0.0;
            lat = 0.0;
            if (e.NewItem.ParentCategory == null)
            {
                lng = e.NewItem.Lng;
                lat = e.NewItem.Lat;
                name = e.NewItem.CategoryName;
            }
            else
            {
                lng = e.NewItem.ParentCategory.Lng;
                lat = e.NewItem.ParentCategory.Lat;
                name = e.NewItem.ParentCategory.CategoryName;
            }
            if (lng != 0.0 && lat != 0.0)
            {
                viewModel.TransferMapPosition(lng, lat, 12);
                viewModel.TransferGraphicInfo(string.Format("{2} - {0},{1}",lng, lat,name));
            }
        }

    }
}
